package com.easy.demo.demos.web.vo;

import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

/**
 * @author zhouchuang
 * @date 2024-11-12 23:03:45
 */
@TableName("t_leave")
public class Leave implements Serializable {
    public enum Status{
        //待提交，审批中，已通过，已拒绝
        WAITCOMMIT("待提交",1),
        APPROVING("待审核",2),
        PASS("已通过",3),
        REJECT("已拒绝",4);
        private String desc;
        private Integer code;
        Status(String desc,Integer code) {
            this.desc = desc;
            this.code = code;
        }
        public static Status byCode(Integer code) {
            for (Status value : Status.values()) {
                if(value.code==code){
                    return value;
                }
            }
            return null;
        }

        public String getDesc() {
            return desc;
        }

        public Integer getCode() {
            return code;
        }
    }

    public Leave() {

    }
    public Leave(String username, Integer days, String reason, Date startDate) {
        this.username = username;
        this.days = days;
        this.reason = reason;
        this.startDate = startDate;
        this.status =  Status.WAITCOMMIT.code;
        this.id = System.currentTimeMillis()+"";
    }

    private String id;
    private Integer status;

    private String username;
    private Integer days;
    private String reason;
    private Date startDate;

    private String instId;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getDays() {
        return days;
    }

    public void setDays(Integer days) {
        this.days = days;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getStatusText(){
        return Status.byCode(status).getDesc();
    }

    public String getInstId() {
        return instId;
    }

    public void setInstId(String instId) {
        this.instId = instId;
    }
}
